package com.juneng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.juneng.common.Condition;
import com.juneng.utils.BeanCopyUtils;
import com.juneng.entity.OrderMsg;
import com.juneng.mapper.OrderMsgMapper;
import com.juneng.service.IOrderMsgService;
import com.juneng.dto.OrderMsgDto;
import com.juneng.dto.OrderMsgQueryDto;
import com.juneng.vo.OrderMsgVo;
import org.springframework.stereotype.Service;
import lombok.AllArgsConstructor;
import java.util.List;
/**
 * 订单商品信息 服务实现类
 *
 * @author zds
 * @since 2021-07-31
 */
@Service
@AllArgsConstructor
public class OrderMsgServiceImpl implements IOrderMsgService {

    protected OrderMsgMapper orderMsgMapper;
    @Override
    public IPage<OrderMsgVo> page(OrderMsgQueryDto dto) {
        IPage<OrderMsgVo> page = Condition.getPage(dto);
        return orderMsgMapper.page(page,dto);
    }

    @Override
    public List<OrderMsg> list(OrderMsgQueryDto dto) {
        QueryWrapper<OrderMsg> queryWrapper = new QueryWrapper<>(BeanCopyUtils.copy(dto,OrderMsg.class));
        return orderMsgMapper.selectList(queryWrapper);
    }

    @Override
    public Integer save(OrderMsgDto dto) {
        return orderMsgMapper.insert(BeanCopyUtils.copy(dto,OrderMsg.class));
    }

    @Override
    public Integer updateById(OrderMsgDto dto) {
        return orderMsgMapper.updateById(BeanCopyUtils.copy(dto,OrderMsg.class));
    }

    @Override
    public Integer deleteLogic(List<Integer> toIntList) {
        return orderMsgMapper.deleteBatchIds(toIntList);
    }

    @Override
    public OrderMsg getById(Integer id) {
        return orderMsgMapper.selectById(id);
    }

    @Override
    public List<OrderMsg> getByOrderId(OrderMsgQueryDto dto) {
        return orderMsgMapper.getByOrderId(dto);
    }
}
